<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增SKU')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sku-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">sku 编码：</label>
                <div class="col-sm-8">
                    <input name="barcode" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">sku 名称：</label>
                <div class="col-sm-8">
                    <input name="skuName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">sku id：</label>
                <div class="col-sm-8">
                    <input name="productId" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">商品档案</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="productId" id="product">
                    <div class="input-group-btn">
                        <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        </ul>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">显示顺序：</label>
                <div class="col-sm-8">
                    <input name="orderNum" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">零售价：</label>
                <div class="col-sm-8">
                    <input name="retailPrice" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">实售价：</label>
                <div class="col-sm-8">
                    <input name="currentPrice" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('pro_sku_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "product/sku"
        $("#form-sku-add").validate({
            focusCleanup: true
        });

        var products = [[${products}]];

        var productData = [];
        $.each(products, function (index, product) {
            var productValue = {};
            productValue.productId = product.productId;
            productValue.productName = product.productName;
            productData.push(productValue);
        });


        $("#product").bsSuggest({
            indexId: 1,
            indexKey: 2,
            data: {
                'value': productData,
                // 'defaults': 'http://ruoyi.vip'
            }
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-sku-add').serialize());
            }
        }
    </script>
</body>
</html>